package com.ysd.Servlet;

import java.io.IOException;
import java.util.ArrayList;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.ysd.dao.impl.ChanPinXiangQingDaoimpl;
import com.ysd.dao.impl.ChanPinXiangQingNeiRongDaoimpl;
import com.ysd.dao.impl.ChanPingShouSuoDaoimpl;
import com.ysd.dao.impl.FeiLeiBiaoIdDaoImpl;
import com.ysd.dao.impl.FenLeiBiaoDaoimpl;
import com.ysd.entity.ChanPinXiangQing;
import com.ysd.entity.FenLeiBiao;

/**
 * Servlet implementation class ProductsServlet
 */
public class ProductsServlet extends HttpServlet {
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		HttpSession session=request.getSession();//创建session对象
		FenLeiBiaoDaoimpl flbd=new FenLeiBiaoDaoimpl();//获得产品分类的实现类
		ArrayList<FenLeiBiao> flb=flbd.getFenLeiBiao();//通过获得产品分类的显现类的数据
		request.setAttribute("flb", flb);//存数据到下个页面
		
		ChanPinXiangQingNeiRongDaoimpl cpxqdnr=new ChanPinXiangQingNeiRongDaoimpl();//获得通过fenleiId查询产品详情的实现类
		int id=Integer.parseInt(request.getParameter("chanPinId"));//获得前台传来的数据
		ArrayList<ChanPinXiangQing> lcpxq=cpxqdnr.getChanPinXiangQingNeiRong(id);//获得通过fenleiId查询产品详情的实现类查询的数据
		request.setAttribute("lcpxq", lcpxq);//存数据到下个页面
		request.setAttribute("id", id);//纯数据到下个页面
		session.setAttribute("lcpxq", lcpxq);//存数据到session
		
		
		
		ChanPinXiangQingDaoimpl cpxqd=new ChanPinXiangQingDaoimpl();//获得通过chanPingId查询产品详情的实现类
		int chanPingId=Integer.parseInt(request.getParameter("chanPinId"));//获得前台传来的产品id
		ArrayList<ChanPinXiangQing> cpxq=cpxqd.getChanPinXiangQing(chanPingId);/////获得通过chanPingId查询产品详情的实现类查询单数据
		request.setAttribute("cpxq", cpxq);//存数据到下个页面
		session.setAttribute("cpxq", cpxq);//存数据到session
		
		
		FeiLeiBiaoIdDaoImpl flbId=new FeiLeiBiaoIdDaoImpl();//获得通过分类表的chanpinId查询类别的实现类
		ArrayList<FenLeiBiao> lflbId=flbId.getFenLeiBiao(id);//获得前台传来的数据和    31行
		request.setAttribute("lflbId", lflbId);
		
		request.getRequestDispatcher("productlist.jsp").forward(request, response);
	}
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
